package fule.com.playandroidkotlin.ui.adapter

import android.view.View
import android.widget.TextView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import fule.com.playandroidkotlin.R
import fule.com.playandroidkotlin.ui.model.ArticleListModel

/**
 * 作者： njb
 * 时间： 2018/8/8 0008-下午 5:50
 * 描述： 文章列表
 * 来源：
 */
class ArticleListAdapter(data: MutableList<ArticleListModel.DatasBean>?) : BaseQuickAdapter<ArticleListModel.DatasBean, BaseViewHolder>(R.layout.item_article_iv, data) {

    override fun convert(helper: BaseViewHolder, item: ArticleListModel.DatasBean) {
        with(helper) {
            setText(R.id.tv_username, item.author)
            setText(R.id.tv_content, item.title)
            setText(R.id.tv_time, item.niceDate)
            if (item.chapterName!!.isNotEmpty()) {
                setText(R.id.tv_type, item.chapterName)
                getView<TextView>(R.id.tv_type).visibility = View.VISIBLE
            } else {
                getView<TextView>(R.id.tv_type).visibility = View.INVISIBLE
            }
        }
    }

}